package com.example.mydemo.company.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mydemo.company.entity.Company;
import com.example.mydemo.company.entity.CompanyAndTypeNature;
import com.example.mydemo.company.entity.CompanyPage;
import com.example.mydemo.company.service.ICompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/company")
public class CompanyController {
    @Autowired
    private ICompanyService companyService;


    @GetMapping("/test")
    public String test() {
        return "CompanyTest";
    }

    @GetMapping("/select")
    public List<Company> select(HttpServletResponse response) {

        return companyService.select();
    }

    @GetMapping("/page")
    public Page<CompanyAndTypeNature> page(
            @RequestParam(defaultValue = "") String name,
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "15") Integer size
    ) {
        return companyService.page(current, size, name);
    }
}
